

/**
 * @file 中间件demo
 */
let SimpleKoa = require('../src/application');

let app = new SimpleKoa();

let responseData = {};

app.use(async (ctx, next) => {
    console.log(ctx.req.url)
    console.log('1 name','tom')
    responseData.name = 'tom';
    await next();
    ctx.body = responseData;
    console.log('body 1')
});

app.use(async (ctx, next) => {
    console.log('2 age',16)
    responseData.age = 16;
    await next();  
    console.log('body 2')     
});

app.use(async (ctx, next) => {
    console.log('3 sex male')
    responseData.sex = 'male';
    await next();
    console.log('body 3')
});
console.log(app.middlewares);
app.listen(3000, () => {
    console.log('listenning on 3000');
});


